package com.guli.edu.controller;


import com.guli.edu.entity.vo.OneSubject;
import com.guli.edu.service.SubjectService;
import com.guli.utils.R;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author ZhaoZhenyu
 * @since 2022-09-25
 */

@Api(description = "课程分类管理")  // swagger用
@RestController
@RequestMapping("/edu/subject")
//@CrossOrigin
public class SubjectController {

    @Autowired
    private SubjectService subjectService;

    @PostMapping("/addSubject")
    public R addSubject(MultipartFile file){
        subjectService.addSubjectByExcel(file, subjectService);
        return R.ok().message("添加课程分类成功");
    }

    @GetMapping("/listSubject")
    public R listSubject(){
        List<OneSubject> oneSubjectList = subjectService.getSubjectList();
        return R.ok().data("items", oneSubjectList);
    }

}

